﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using NENAData.LINQ;
using NENAData.NENAMember;

namespace NENAData.Email
{
    public class Referral
    {

        public static void SendMemberReferralEmail(int intMemberId, string strReferralId)
        {
            MailMessage oMessage = new MailMessage();
            StringBuilder strbuilder = new StringBuilder();

            NENAData.NENAMember.NENAMember oNENAMember = new NENAData.NENAMember.NENAMember();
            //add member data to the email including name and email
            Member oMember = oNENAMember.GetMember(intMemberId);

            strbuilder.AppendFormat("Hi {0},<br /><br />", oMember.FirstName);
            strbuilder.Append(@"NENA is continuing its recruiting incentive program for 2011! <br />
                With this email, you have received instructions on how to have 
                member referrals attached to your name. The only way to attach members to your 
                name is through this code, it can not be done after they have registered.
                <br />
                <br />
                When NEW members register and use the code you provide them, you will receive 
                credit for one referral. Once you achieve a certain number of referrals, you are 
                eligible to receive one of the referral gifts listed below. What is even more 
                exciting is that you will receive the 10 and 25 member gifts as soon as you 
                achieve those levels (and you can get each in the same year! The conference 
                gifts will be awarded only once per year and to the level that you achieve. 
                Prizes are non-transferable so make sure you put the conference dates in your 
                calendar now if you&#39;re going for our top-level prizes!
                <br />
                <br />
                Here are the prizes for the program:
                <br />
                <br />
                10 Members – Free NENA Membership for you for next year
                <br />
                25 Members – Choice of Emergency Nursing Book (List of 5 to choose from will be 
                on website)
                <br />
                50 Members – Free NENA Conference Enrollment for Next Conference
                <br />
                100 Members – Free NENA Conference With Air Travel Paid (Within Canada)
                <br />
                200 Members – Free NENA Conference With Air Travel and Hotel Paid (Within 
                Canada)
                <br />
                400 Members – Two Free Years at the NENA Conference with Travel and Hotel Paid 
                (Within Canada)
                <br />
                <br />
                So get yourselves recruiting at work, courses and everywhere else (we don&#39;t 
                recommend billboards on street corners or coffee shops...but you never know...).
                <br />
                <br />
                Updates to the plan and questions can be asked on the website at this link<br />
                <a href='http://nena.ca/blogs/about/archive/2010/06/30/new-member-recruitment-incentives-are-planned.aspx'>
                http://nena.ca/blogs/about/archive/2010/06/30/new-member-recruitment-incentives-are-planned.aspx</a><br />
                <br />");

            strbuilder.AppendFormat("Provide this referral code to new member referrals: {0}", strReferralId);
            strbuilder.Append("<br />You can also provide them with this link if you prefer; this link will credit your account with a referral once they are a paid member. <br />");
            strbuilder.AppendFormat("<a href='http://membership.nena.ca/Disclaimer.aspx?ReferralId={0}'>http://membership.nena.ca/Disclaimer.aspx?ReferralId={0}</a> <br />", strReferralId);
            strbuilder.Append("<br />From Your NENA Board of Directors");
            
            oMessage.From = new MailAddress("president@nena.ca", "NENA President");
            oMessage.To.Add(new MailAddress(oMember.EmailAddress));
            //oMessage.Bcc.Add(new MailAddress("websiteadministrator@nena.ca"));

            oMessage.IsBodyHtml = true;
            oMessage.Subject = "NENA Membership Referral Program";
            oMessage.Body = strbuilder.ToString();

            SmtpClient client = new SmtpClient();
            client.Send(oMessage);

        }

    }
}
